/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/




#if !defined(AFX_PGLGRAPHDLGLIST_H__3DD7E6E3_3FDB_4FEE_B845_19C6FE7DE1A7__INCLUDED_)
#define AFX_PGLGRAPHDLGLIST_H__3DD7E6E3_3FDB_4FEE_B845_19C6FE7DE1A7__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <afxmt.h>
#include <pgl/mfc/PGLDialog.h>

/*! \brief A manager class for all PGL dialog boxes

\ingroup PGLMFCGroup
*/
class PGLMFC_EXT_CLASS CPGLDialogList
{
public:
	//! \name Constructors
	//@{
	//! Default constructor
	CPGLDialogList();
	virtual ~CPGLDialogList();
	//@}

	//! \name Container methods
	//@{
	/*! \brief Show modeless dialog with region
	*/
	CPGLDialog* Create( CPGLRegionPtr pRegion );

	/*! \brief Add and create dialog

	Call this function to add the dialog to the manager. The manager will handle the dialog creation for you.
	Note that _pGraphDlg must be allocated on the head and will be destroyed by the manager.
	*/
	void AddHead(CPGLDialog* pGraphDlg);
	//! Remove and destroy a dialog
	void Remove(CPGLDialog* pGraphDlg);
	//! Remove and destroy all current modeless dialog attached to the manager
	void RemoveAll();
	//! Remove and destroy all hidden modeless dialogs
	void RemoveHidden();
	//! returns true if empty
	bool IsEmpty()			{ return m_lPlots.empty();};
	//! return number of hidden, visible dialogs
	size_t GetSize()			{ return m_lPlots.size();};
	//! return number of visible dialog windows
	size_t GetVisibleSize();
	//! return number of hidden dialog
	size_t GetHiddenSize();
	//! return true if dialog is in list
	bool IsInList(CPGLDialog* pGraphDlg);
	//! Find dialog by ID
	CPGLDialog* Find( DWORD dwID);
	//! find from region
	CPGLDialog* FindFromRegion( DWORD dwRegionID);
	//@}

	//! \name Misc
	//@{
	//! Makes all dialogs visible
	void ShowAll();
	//@}
protected:
	//!  \name Protected attributes
	//@{
	//! list of pointers to dialogs
	std::list<CPGLDialog*> m_lPlots;
	//! multi-threading
	CMutex m_ThreadLock;
	//@}
};

class PGLMFC_EXT_CLASS CPGLDialogListSingleton : singletons::TSingleton< CPGLDialogList , 1 >{};

#endif // !defined(AFX_PGLGRAPHDLGLIST_H__3DD7E6E3_3FDB_4FEE_B845_19C6FE7DE1A7__INCLUDED_)
